<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>考试页面</title>
    <link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
    <script>
        let remainingTime = {{ remaining_time }};
        let interval;

        function startTimer() {
            const timerElement = document.getElementById('timer');
            interval = setInterval(() => {
                if (remainingTime > 0) {
                    remainingTime--;
                    const minutes = Math.floor(remainingTime / 60);
                    const seconds = remainingTime % 60;
                    timerElement.textContent = `剩余时间: ${minutes} 分钟 ${seconds} 秒`;
                } else {
                    clearInterval(interval);
                    alert("考试时间到，系统将自动提交。");
                    document.getElementById('examForm').submit();
                }
            }, 1000);
        }

        window.onload = startTimer;

        function submitExam() {
            clearInterval(interval);
            document.getElementById('examForm').submit();
        }
    </script>
</head>
<body class="bg-moonlight-purple">
    <div class="header text-white">
        <span id="timer">剩余时间: 正在计算...</span>
    </div>

    <div class="container mt-5">
        <h1 class="text-center text-white">考试页面</h1>
        <div class="exam-content">
            <!-- 在这里添加考试题目内容 -->
            <p class="text-white">考试题目示例：这是一个样例题目。请在此处填写您的答案。</p>
        </div>

        <form id="examForm" method="POST" action="{{ url_for('submit_exam', class_name=class_name, exam_name=exam_name) }}">
            <button type="button" onclick="submitExam()" class="btn btn-light w-100">提交考试</button>
        </form>
    </div>
</body>
</html>
